package com.alquimia.identityaccess.infraestructura.config;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by Ivo on 12/07/2014.
 */
public abstract class AbstractSessionHibernate {

    private SessionFactory sessionFactory;

    protected AbstractSessionHibernate() {
        super();
    }

    protected AbstractSessionHibernate(SessionFactory aSessionFactory) {
        this();

        this.setSessionFactory(aSessionFactory);
    }

    protected Session session() {
        return this.sessionFactory().getCurrentSession();
    }

    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    public SessionFactory sessionFactory() {
        return this.sessionFactory;
    }

}
